import matplotlib.pyplot as plt
import numpy as np
# 输入数据
apples = [30,25,22,36,21,29]
oranges = [24,33,19,27,35,20]

# 设置组数
num_groups = len(apples)
# 创建图形
fig,ax = plt.subplots()
# 定义x轴
indices = np.arange(num_groups)
# 设置柱子宽度核不透明度
bar_width = 0.4
alpha = 0.6
# 画出数值
hits_apples = plt.bar(indices,apples,bar_width,alpha=alpha,color='g',label='Apple')
hist_oranges = plt.bar(indices+bar_width,oranges,bar_width,alpha=alpha,color='b',label='Orange')
# 设置图形参数
plt.xlabel("Month")
plt.ylabel("Production quantity")
plt.title("Comparing apples and oranges")
plt.xticks(indices+bar_width,('Jan','Feb','Mar','Apr','May','Jun'))
plt.ylim([0,45])
plt.legend()
plt.tight_layout()
plt.show()